﻿@model Zatify.WebUI.Areas.Admin.Models.Reports.SystemUsersReportViewModel
@{
    ViewBag.Title = "System Users Report";
    Layout = "~/Areas/Admin/Views/Shared/_AdminReportsLayout.cshtml";
}
@section Scripts
{
    <script type="text/javascript">

        function postSystemUsersFiltersForm() {

            $("#page").val($("#pageNum").val());
            $("#systemUsersFiltersForm").submit();
        }

        function filterSystemUsersForm() {

            $("#page").val(1);
            $("#systemUsersFiltersForm").submit();
        }
    
    </script>
}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top" bgcolor="#d3dfe6">
            <div class="report_filter_area">
                <h6>
                    Report Filters</h6>
                <p>
                    @using (Html.BeginForm("SystemUsers", "Reports", FormMethod.Post, new { id = "systemUsersFiltersForm" }))
                    {
                        @Html.Hidden("page", 1)
                        <table border="0">
                            <tr>
                                <td>
                                    <strong>Users in status :</strong>
                                </td>
                                <td>
                                    @Html.DropDownList("activeUsers", (IEnumerable<SelectListItem>)ViewData["Statuses"], new { @class = "apps_selectbox" })
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong>Users in roles :</strong>
                                </td>
                                <td>
                                    @Html.DropDownList("role", (IEnumerable<SelectListItem>)ViewData["Roles"], new { @class = "apps_selectbox" })
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input type="submit" class="btn apps_btn apps_gray_btn" value="Search" onclick="filterSystemUsersForm();" />
                                </td>
                            </tr>
                        </table>
                    }
                </p>
            </div>
        </td>
    </tr>
    <tr>
        <td valign="top">
            <div class="report_result_area">
                <h5>
                    Active/Inactive Users</h5>
            </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th width="15%">
                        User ID
                    </th>
                    <th width="14%">
                        Email
                    </th>
                    <th width="14%">
                        Phone
                    </th>
                    <th width="14%">
                        Role
                    </th>
                    <th width="15%">
                        Status
                    </th>
                </tr>
                @foreach (var user in Model.SystemUsers)
                {
                    <tr>
                        <td>
                            @user.Login
                        </td>
                        <td>
                            @user.Email
                        </td>
                        <td>
                            @user.Phone
                        </td>
                        <td>
                            @user.Role
                        </td>
                        <td>
                            @(user.IsActive ? "Active" : "Inactive")
                        </td>
                    </tr>
                }
            </table>
            <!--start pagination-->
            <div class="zatify_pagination">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        @Html.PageLinks(Model.PagingInfo, x => Url.Action("SystemUsers", new
                   {
                       page = x,
                       activeUsers = Model.ActiveUsers,
                       role = Model.Role
                   }),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_first_btn.png"),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_last_btn.png"),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_back.png"),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_next.png"))
                        <td width="6%">
                            Page No:
                        </td>
                        <td width="11%">
                            @Html.DropDownList("pageNum", (IEnumerable<SelectListItem>)ViewData["pagesCount"], new { onchange = "postSystemUsersFiltersForm();", @class = "select_box" })
                        </td>
                        <td width="2%">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/excel_icon.png")" alt="" title="back" border="0" />
                        </td>
                        <td class="pagination_no" width="15%">
                            <a href="@Url.Action("SystemUsersReport", "Reports", new { role = Model.Role, activeUsers = Model.ActiveUsers, reportExportType = Zatify.WebUI.Areas.Admin.Models.Reports.ReportExportType.Excel })">
                                Export to Excel</a>
                        </td>
                        <td width="2%">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/pdf_icon.png")" alt="" title="back" border="0" />
                        </td>
                        <td class="pagination_no" width="15%">
                            <a href="@Url.Action("SystemUsersReport", "Reports", new { role = Model.Role, activeUsers = Model.ActiveUsers, reportExportType = Zatify.WebUI.Areas.Admin.Models.Reports.ReportExportType.PDF })">
                                Export to PDF</a>
                        </td>
                        <td width="2%">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/printing_icon.gif")" alt="" title="back" border="0" />
                        </td>
                        <td class="pagination_no" width="15%">
                            <a href="@Url.Action("SystemUsersReport", "Reports", new { role = Model.Role, activeUsers = Model.ActiveUsers, reportExportType = Zatify.WebUI.Areas.Admin.Models.Reports.ReportExportType.Print })">
                                Printing</a>
                        </td>
                        <td width="15%">
                            <span class="page_no_info">@Model.PagingInfo.TotalItems items in @Model.PagingInfo.TotalPages
                                pages</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="clearfix">
            </div>
            <!--end pagination-->
        </td>
    </tr>
</table>
